package com.taoym.voucher.admin.service.impl;

import com.taoym.voucher.admin.entity.vo.GetDicEnumVO;
import com.taoym.voucher.admin.service.DicEnumService;
import com.taoym.voucher.common.constant.DicEnumTypeConstant;
import com.taoym.voucher.common.enums.*;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @coder taoym
 * @datetime 2021/6/5 10:18
 * @desc 枚举字典服务接口实现类
 */
@Service
public class DicEnumServiceImpl implements DicEnumService {

    @Override
    public List<GetDicEnumVO> getDicEnum(String type) {

        EnumsCommon[] enumsCommons = null;
        if (type.equals(DicEnumTypeConstant.ACTIVITY_ORDER_STATUS)) {
            enumsCommons = ActivityOrderStatusEnum.values();
        } else if (type.equals(DicEnumTypeConstant.DATE_CONDITION)) {
            enumsCommons = DateConditionEnum.values();
        } else if (type.equals(DicEnumTypeConstant.QUARTZ_JOB_GROUP_ENUM)) {
            enumsCommons = QuartzJobGroupEnum.values();
        } else if (type.equals(DicEnumTypeConstant.USER_WITHDRAW_STATUS_ENUM)) {
            enumsCommons = UserWithdrawStatusEnum.values();
        } else if (type.equals(DicEnumTypeConstant.TEXT_TYPE_ENUM)) {
            enumsCommons = TextTypeEnum.values();
        } else if (type.equals(DicEnumTypeConstant.IMAGE_TYPE_ENUM)) {
            enumsCommons = ImageInfoTypeEnum.values();
        } else if(type.equals(DicEnumTypeConstant.ACTIVITY_PLATFORM_TYPE_ENUM)){
            enumsCommons = ActivityPlatformEnum.values();
        }

        if(ObjectUtils.isEmpty(enumsCommons)){
            return null;
        }

        List<GetDicEnumVO> getDicEnumVOS = new ArrayList<>(enumsCommons.length);
        for (EnumsCommon value : enumsCommons) {
            GetDicEnumVO getDicEnumVO = new GetDicEnumVO();
            getDicEnumVO.setCode(value.getCode());
            getDicEnumVO.setMsg(value.getMsg());
            getDicEnumVOS.add(getDicEnumVO);
        }

        return getDicEnumVOS;
    }
}
